package com.vcc.service.boss.response.user;

import com.vcc.core.util.DateUtil;
import com.vcc.core.util.RegexUtil;
import com.vcc.core.util.StringUtil;
import com.vcc.data.entity.Role;
import com.vcc.data.entity.User;
import com.vcc.data.entity.Wallet;
import com.vcc.service.boss.response.baseVo.BossBaseVo;
import com.vcc.service.boss.response.wellat.WalletVoBoss;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

@EqualsAndHashCode(callSuper = true)
@Data
@Setter
@Getter
public class UserVoBoss extends BossBaseVo implements Serializable {

    private String username;

    private String account;

    private String email;

    private String registerDate;

    private String roleCode;

    private String roleName;

    private String remark;

    private Integer status;

    private Long parentId;

    private List<WalletVoBoss> walletVos;

    private Long dealerId;

    private String parentAccount;

    private String dealerAccount;

    private String registerAccount;

    private Integer registerCount;

    private String adminRemark;


    public UserVoBoss() {
    }

    public UserVoBoss(User user, Role role, String registerAccount, List<Wallet> wallets) {
        super.setId(user.getId());
        this.username = user.getUsername();
        this.account = user.getAccount();
        this.email = user.getEmail();
        this.registerDate = DateUtil.format(user.getCreateDate());
        this.roleCode = role.getCode();
        this.roleName = role.getName();
        this.remark = user.getRemark();
        this.status = user.getStatus();
        this.parentAccount = user.getParentAccount();

        this.dealerAccount = user.getDealerAccount();

        this.walletVos = wallets.stream().map(WalletVoBoss::new).collect(Collectors.toList());
        this.dealerId = user.getBeLongToDealer();
        this.parentId = user.getParentId();
        this.registerAccount = registerAccount;
        this.registerCount = user.getRegisterCount();
        this.adminRemark = user.getAdminRemark();
    }
}
